<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Echarts 使用示例</title>
    <style>
        *{ margin: 0; padding: 0; box-sizing: border-box;}
        .chart{ width: 300px; height: 300px; background-color: #F7F7F7; margin: 15px;}
    </style>
</head>
<body>
    <div class="chart" id="chart1"></div>

<!-- <script src="http://www2.456wsq.com/Public/Admin/js/echarts.min.js"></script> -->
<script src="dish/echarts.min.js"></script>
<script>
    var chart = echarts.init(document.getElementById('chart1')),
        rem = 100,
        legendData = (data) => {
            let arr = [];
            data.map(item => {
                arr.push({
                    name: item.name,
                    textStyle: { fontSize:0.14 * rem, color:'#fff'}
                });
            });
            return arr;
        }, option, option2;
    option = {
        color: ['#009847', '#F19716', '#E30920'],
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b}: {c} ({d}%)'
        },
        series: [
            {
                name: '健康码',
                type: 'pie',
                // radius: ['65%', '80%'],
                radius: '80%',
                // hoverOffset: 0.1 * rem,
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                },
                data: [
                    { name: '绿码', value: 77894},
                    { name: '黄码', value: 12845},
                    { name: '红码', value: 3362}
                ]
            },
            {
                name: '疫苗接种',
                type: 'pie',
                radius: ['65%', '80%'],
                // hoverOffset: 0.1 * rem,
                label: {
                    formatter: '{per|{d}}{icon|%}\n{num|{c}次}',
                    show: false,
                    position: 'center',
                    fontSize: 0.14 * rem,
                    rich: {
                        icon: {
                            fontSize: 0.18 * rem
                        },
                        per: {
                            fontSize: 0.30 * rem,
                            fontWeight: 'bold'
                        },
                        num: {
                            color: '#fff',
                            fontSize: 0.14 * rem
                        }
                    }
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: 0.3 * rem,
                        fontWeight: 'bold'
                    }
                },
                data: [
                    { name: '已接种', value: 27894},
                    { name: '接种中', value: 12845},
                    { name: '未接种', value: 3362}
                ]
            }
        ]
    };

    option2 = {
        title: {
            text: '某站点用户访问来源',
            subtext: '纯属虚构',
            left: 'center'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left',
        },
        series: [
            {
                name: '访问来源',
                type: 'pie',
                radius: '50%',
                data: [
                    {value: 1048, name: '搜索引擎'},
                    {value: 735, name: '直接访问'},
                    {value: 580, name: '邮件营销'},
                    {value: 484, name: '联盟广告'},
                    {value: 300, name: '视频广告'}
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };

    chart.setOption(option);
</script>
</body>
</html>